/*
	@file: log/source/logger/OStreamLogger.cpp
	@author: Wolfhead
 */
#include "logger/OStreamLogger.h"
#include <iostream>
#include <boost/foreach.hpp>

namespace logger
{

OStreamLogger::OStreamLogger(std::ostream& os)
	: m_os(os)
{

}

int OStreamLogger::log(const std::string& message)
{
	boost::lock_guard<boost::mutex> lock(m_mutex);
	m_os << message << std::endl;
	return 0;
}

int OStreamLogger::log(const Logger::SpliteQueue& message_queue)
{
	boost::lock_guard<boost::mutex> lock(m_mutex);
	
	BOOST_FOREACH(const LogDataPtr& data, message_queue)
	{
		m_os << data->message << std::endl;
	}
	
	return 0;
}


}//namespace logger

